package cn.edu.gzhu.workOrderManagement.intercepter;

import cn.edu.gzhu.workOrderManagement.enumeration.UserAuthorityEnum;
import io.jsonwebtoken.Claims;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Component
public class TeamManagementInterceptor implements HandlerInterceptor {
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Claims claims =(Claims)request.getAttribute("claims");
        UserAuthorityEnum userAuthorityEnum = UserAuthorityEnum.value2Object (claims.get("authority").toString());
        return userAuthorityEnum.equals(UserAuthorityEnum.ADMIN);
    }
}
